{%extends 'myadmin/public/base.html' %}
{% block con-header %}
<div class="container-fluid am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
            <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span>商品分类列表</div>
           
        </div>
        <div class="am-u-lg-3 tpl-index-settings-button">
            <button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>
        </div>
    </div>

</div>
{%endblock%}



{% block con-body %}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
               
                <div class="widget-body  am-fr">

                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 条件搜索 -->
                    <form >
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                            <div class="am-form-group tpl-table-list-select">
                                <select name="type" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                                  <option value="all" >所属分类</option>
                      
                                
                                </select>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                            <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                <input type="text" name="keywords" class="am-form-field " value="{{request.GET.ke }}" >
                                <span class="am-input-group-btn">
                                  <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>
                                </span>
                            </div>
                        </div>
                    </form>
                    <!-- 展示内容 -->
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                
                                    <th>ID</th>
                                    <th>分类名</th>
                                    <th>所属父类</th>
                                    <th>分类结构</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            	{% for v in ob %}
                                <tr class="gradeX">
                                    
                                    <td class="am-text-middle vid">{{ v.id }}</td>
                                   
                                    <td class="am-text-middle">{{ v.name }}</td>
                                    <td class="am-text-middle">{{ v.pname }}</td>
                                    <td class="am-text-middle">{{ v.path }}</td>
                  
                                
                                   
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{% url 'admin_type_edit' v.id %}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>

                                </tr>
                            	{% endfor %}

                             
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">

                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
                                {% load pagetag %}

                                {% showpage ob.paginator.num_pages request %}




                            </ul>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('.tpl-table-black-operation-del').click(function(){
        a=$(this)
        vid=$(this).parents(".gradeX").find(".vid").text()
        //发送ajax执行逻辑删除
        $.get("{% url 'admin_type_del' %}",{"vid":vid},function(data){
            if(data["status"]==0){
                a.parents("tr").remove()
                alert(data["msg"]);
            }else{alert(data["msg"]);}

        },'json')
        
      
        return false;
        
    })

    // $('.am-btn').click(function(){
    //     // 获取表单填写的值
    //     val=$(this).parent().prev().val()
    //     $.get('{% url "admin_type_list" %}',{"val":val},function(data){
    //         alert("123");
    //     })
       
    // })

</script>
{% endblock %}